package cn.gogpay.duoim.sdk.constant;

public class IMRespCode {

    private final Integer code;

    private final String message;

    public IMRespCode(Integer code, String message) {
        this.code = code;
        this.message = message;
    }

    public Integer getCode() {
        return code;
    }

    public String getMessage() {
        return message;
    }

    /**
     * 成功
     *
     * @return 状态码
     */
    public static IMRespCode success() {
        return new IMRespCode(-1, "");
    }

    /**
     * 成功
     *
     * @return 状态码
     */
    public static IMRespCode ok() {
        return new IMRespCode(0, "");
    }

    /**
     * 错误
     *
     * @return 状态码
     */
    public static IMRespCode error() {
        return new IMRespCode(1000, "SDK异常");
    }

    /**
     * 错误
     *
     * @return 状态码
     */
    public static IMRespCode api() {
        return new IMRespCode(1001, "接口异常");
    }

    public static IMRespCode parse() {
        return new IMRespCode(1003, "参数解析异常");
    }

    public static IMRespCode refuse() {
        return new IMRespCode(1004, "回调拒绝");
    }

    @Override
    public String toString() {
        final StringBuilder sb = new StringBuilder("{");
        sb.append("\"code\":")
                .append(code);
        sb.append(",\"message\":\"")
                .append(message).append('\"');
        sb.append('}');
        return sb.toString();
    }
}
